<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/2/1
 * Time: 9:49
 */

namespace app\common;


class AliPayAccount
{
    public $payee_account;
    public $real_name;

    /**
     * AliPayAccount constructor.
     * @param $payee_account
     * @param $real_name
     */
    public function __construct($payee_account, $real_name)
    {
        $this->payee_account = $payee_account;
        $this->real_name = $real_name;
    }

    static function build_by_json($str)
    {
        $arr = json_decode($str, true);
        if (
            isset($arr["payee_account"]) &&
            isset($arr["real_name"])
        ) {
            return new self($arr["payee_account"], $arr["real_name"]);
        } else {
            return new self("", "");
        }
    }

    /**
     * @return mixed
     */
    public function getPayeeAccount()
    {
        return $this->payee_account;
    }

    /**
     * @param mixed $payee_account
     */
    public function setPayeeAccount($payee_account)
    {
        $this->payee_account = $payee_account;
    }

    /**
     * @return mixed
     */
    public function getRealName()
    {
        return $this->real_name;
    }

    /**
     * @param mixed $real_name
     */
    public function setRealName($real_name)
    {
        $this->real_name = $real_name;
    }

    function __toString()
    {
        // TODO: Implement __toString() method.
        if ($this->payee_account && $this->real_name) {
            return json_encode($this);
        } else {
            abort("AliPayAccount is NULL while running __toString");
        }
    }

}